//
//  Session.m
//  ShanMei
//
//  Created by huazi on 15/4/12.
//  Copyright (c) 2015年 huazi. All rights reserved.
//

#import "Session.h"

@implementation Session
- (instancetype)initWithDic:(NSDictionary *)dic {
    if (self =[super init]) {
        _userId =[dic objectForKeyNotNull:@"userId"];
        _nickName =[dic objectForKeyNotNull:@"nickName"];
        _photoUrl =[dic objectForKeyNotNull:@"photoUrl"];
        _content =[dic objectForKeyNotNull:@"content"];
        _sendTime =[dic objectForKeyNotNull:@"sendTime"];
    }
    return self;
}
- (instancetype)initWithReceiveDic:(NSDictionary *)dic{
    if (self =[super init]) {
        _userId =[dic objectForKeyNotNull:@"userId"];
        _nickName =[dic objectForKeyNotNull:@"nickName"];
        _photoUrl =[dic objectForKeyNotNull:@"photoUrl"];
        _sendTime =[dic objectForKeyNotNull:@"sendTime"];
        if ([[dic objectForKeyNotNull:@"msgType"] isEqualToString:@"3"]) {
            _content =@"[图片]";
        }
        else if ([[dic objectForKeyNotNull:@"msgType"] isEqualToString:@"2"]) {
            _content =@"[语音]";
        }
        else {
            _content =[dic objectForKeyNotNull:@"content"];
        }
    }
    return self;
}
@end
